import torch
import torch.nn as nn

model = nn.Conv2d(1, 1, 3, padding=1)
criterion = nn.BCELoss(reduction='mean')
x = torch.randn(1, 1, 16, 16)
y = torch.randint(0, 2, size=(1, 1, 16, 16)).type(torch.FloatTensor)
preds = nn.Sigmoid()(model(x))
loss = criterion(preds, y)
print(loss)